package jmine.tec.report.impl.table.csv;

import java.io.IOException;
import java.io.OutputStream;

import jmine.tec.report.api.table.ReportCell;
import jmine.tec.report.impl.table.ReportTableBuilder;

/**
 * Renderizador de células do tipo String.
 * 
 * @author katsuo.ogawa
 */
public class StringCellCSVRenderer implements ReportCellCSVRenderer {

    /**
     * {@inheritDoc}
     */
    public void render(OutputStream outputStream, ReportCell cell, String charset) throws IOException {
        StringBuilder value = new StringBuilder();
        if (cell.getValue() != null) {
            value.append(cell.getValue().toString());
        }
        outputStream.write(value.toString().getBytes(charset));
    }

    /**
     * {@inheritDoc}
     */
    public String getRendererType() {
        return ReportTableBuilder.TYPE_STRING;
    }

}
